<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>

    function sum(n) {
      var sum1 = 1
      for(var i=1; i<=n; i++){
        sum1*=i;
    }
         return sum1;
    }
    

    function total(n){
      var res = 0
      for(var i=1; i<=n; i++){
        res += sum(i)
    }
      return res;
    }
    console.log(total(3));

      
    
  </script>
</body>
</html>